<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>支付宝支付-支付测试页面</title>
    <script type="text/javascript" src="/static/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/static/md5.js"></script>
    <script type="text/javascript">

        function pay() {
            var key = uuid();
            var privateKey = "Apin@123456";
            var timestamp = (new Date()).valueOf();
            var sign = hex_md5(key+privateKey+timestamp);
            $.ajax({
                headers: {
                    timestamp:timestamp,
                    key:key,
                    sign:sign
                },
                type:"POST",
                url : "/v1.0/alipay/consume",
                data:JSON.stringify({
                    "userUUID": $("#userUUID").val(),
                    "orderId": $("#orderId").val(),
                    "orderName": $("#orderName").val(),
                    "orderDesc": $("#orderDesc").val(),
                    "outOrderId": $("#outOrderId").val(),
                    "txnAmt": $("#txnAmt").val()
                }),
                contentType : "application/json",
                async:false,
                dataType: "html",
                success:function(data){
                    $("body").html(data);
                },
                error: function(data){
                },
                complete: function(){
                }
            });
        }

        function uuid() {
            var s = [];
            var hexDigits = "0123456789abcdef";
            for (var i = 0; i < 36; i++) {
                s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
            }
            s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
            s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
            s[8] = s[13] = s[18] = s[23] = "-";

            var uuid = s.join("");
            return uuid;
        }

    </script>
</head>
<body>
    <input id="userUUID" value="useruuiduseruuid004"><br />
    <input id="orderId" value="orderidorderid004"><br />
    <input id="orderName" value="ordernameordername004"><br />
    <input id="orderDesc" value="orderdescorderdesc004"><br />
    <input id="outOrderId" value="outOrderIdoutOrderId004"><br />
    <input id="txnAmt" value="1"><br />



    <button name="button" onclick="pay()">提交</button>
</body>
</html>